<div class="page_heading_text">Cart</div>
<div class="clear"></div> 

<div class="clear" style="margin-bottom:20px;"></div>
<!-- Start Book Package -->  
<? if($is_loggedin) :?>
<div class="my_account_area_main">
	<span style="font-weight:bold; font-size:24px;"><?=$this->session->userdata('fullname')?></span> 
	Member since <?=mysqldatetime_to_date($this->session->userdata('created'), 'l, F jS Y'); ?> 
</div>
<? endif;?>
<div class="my_account_area_main">
	<div class="my_account_top_border"></div>
	<? if($is_loggedin) :?>
	<div class="my_account_menu_top_border">
		<?php $this->load->view ("includes/my-account-menubar");?>
	</div>
	<? endif;?>
	<div class="orders_profile_main_div">
		<div class="orders_dv1">
			<div class="handler">My cart</div>
			<div class="my_account_heading_div_hei_con">
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Serial Number</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Products</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Quantity</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading">Price</div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total">Total</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total"></div>
				</div>
			</div>
			<?php 
				$cartArray = $this->session->userdata('cartdata');
				if($cartArray && is_array($cartArray) && count($cartArray) > 0) :
					$cart_total = 0;
					$i = 0;
					foreach ($cartArray as $book_id => $item) :
			?>
			<!-- Loop Starts -->
			<div class="order_history_main_div" id="cart_item_<?=$book_id?>">
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=(++$i)?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=$item['book_name']?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=$item['quantity']?></div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><?=number_format($item['price'], 2, '.', ',')?></div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total_down">
						<?php 
							$total= $item['quantity'] * $item['price'];
							$cart_total += $total;
							print number_format($total, 2, '.', ',');
						?>
					</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total_down">
						<div class="order_history_edit_icon">
							<a href="<?=book_url($book_id, $item['book_name'])?>">
								<img src="<?=base_url('images/view-icon.gif')?>" width="16" height="16" border="0" alt="View" />
							</a>
						</div>
						<div class="order_history_edit_icon">
							<a href="<?=site_url('cart/delete/' . $book_id)?>" id="cart_delete_item_<?=$book_id?>" class="cart-delete-item">
								<img src="<?=base_url('images/delete-icon.png')?>" width="16" height="16" border="0" alt="Delete" />
							</a>
						</div>
					</div>
				</div> 
			</div>
			<!-- Loop Ends -->
			<?php 
					endforeach; 
			?>
			<!-- Loop Starts -->
			<div class="order_history_main_div">
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down"><b>Total:</b></div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total_down">
						<span id="cart_total_price"><?=number_format($cart_total, 2, '.', ',')?></span>
					</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total_down">
						<div class="order_history_edit_icon">
							&nbsp;
						</div>
						<div class="order_history_edit_icon">
							&nbsp;
						</div>
					</div>
				</div> 
			</div>
			<!-- Loop Ends -->
			<?php
				else: 
			?>
			<!-- Loop Starts -->
			<div class="order_history_main_div">
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">No order available</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field">
					<div class="order_history_heading_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field_total">
					<div class="order_history_heading_total_down">&nbsp;</div>
				</div>
				<div class="order_heading_profile_field_edit">
					<div class="order_history_heading_total_down">
						<div class="order_history_edit_icon">
							&nbsp;
						</div>
						<div class="order_history_edit_icon">
							&nbsp;
						</div>
					</div>
				</div> 
			</div>
			<!-- Loop Ends -->
			<?php endif; ?>
		</div>
	</div>
	<div class="clear"></div>
</div> 
<div class="clear"></div> 
<div class="clear" style="margin-bottom:20px;"></div>